/*
Generates figure 5.
*/

set more off

clear all

use "$data/incFinalMonthlyTehsil", clear

set scheme s1mono

//Aggregate violence by district-month.
collapse (sum) incidents totCas incidents_prop totCas_prop (first) qtryr, by(monyr distn)

drop if distn==.

reshape wide incidents totCas incidents_prop totCas_prop, i(monyr) j(distn)

//Labels for graphs
global d1 "Bajaur"
global d2 "Khyber"
global d3 "Kurram"
global d4 "Mohmand"
global d5 "NWA"
global d6 "Orakzai"
global d7 "SWA"

label variable monyr ""

//Generate graphs
line incidents1 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon1) title($d1, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line incidents2 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon2) title($d2, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line incidents3 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon3) title($d3, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line incidents4 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon4) title($d4, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line incidents5 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon5) title($d5, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line incidents6 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon6) title($d6, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line incidents7 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(incMon7) title($d7, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))

//Compile graphs into Figure 5a
gr combine incMon1 incMon2 incMon3 incMon4 incMon5 incMon6 incMon7, r(3)
gr export "$figures/incMon.pdf", replace

line totCas1 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon1) title($d1, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line totCas2 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon2) title($d2, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line totCas3 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon3) title($d3, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line totCas4 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon4) title($d4, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line totCas5 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon5) title($d5, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line totCas6 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon6) title($d6, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))
line totCas7 monyr, xline(576, lp(shortdash)) ytitle("") xtitle("") ylabel(, angle(0) labsize(small)) nodraw name(casMon7) title($d7, size(medium)) xlabel(516 "2003" 528 "2004" 540 "2005" 552 "2006" 564 "2007" 576 "2008" 588 "2009" 600 "2010" 612 "2011" 624 "2012", angle(45) labsize(small))

//Compile graphs into Figure 5b
gr combine casMon1 casMon2 casMon3 casMon4 casMon5 casMon6 casMon7, r(3)
gr export "$figures/casMon.pdf", replace
